package com.yuan.mint.utils;

import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.widget.ImageView;

public class ImgAsyncTask extends AsyncTask<String, Void, Bitmap> {

    private String path;
    private ImageView img;

    public ImgAsyncTask(ImageView img) {
        this.img = img;
    }

    @Override
    protected Bitmap doInBackground(String... params) {
        path = params[0];
        Bitmap bitmap = MintUtils.downloadImage(params[0]);
        return bitmap;
    }

    @Override
    protected void onPostExecute(Bitmap result) {
        super.onPostExecute(result);
        if (path != null && path.equals(img.getTag())) {
            img.setImageBitmap(result);
        }
    }

}
